Mouse Roller & DBGrid

Otázka od: Ladislav Novak

6. 8. 2004 23:49

Zdravim vsechny,

a prosim o pomoc...
Jak zaridit, abych pomoci rolleru mysi v DBGridu pokracoval i na dalsi
stranku zaznamu...? Asi trochu hodne laicky receno..
Zkratka momentalne mam v DBGridu zobrazenou stranku zaznamu a rollerem
se muzu pohybovat pouze v ramci zaznamu teto stranky..
Jak plynule pokracovat na dalsi...?

D6, FB 1.5

Diky moc,

Lada


Odpovedá: Petr Fiser

9. 8. 2004 6:53

Ja jsem to vyresil upravenim komponenty DBGrid.

unit DBGridEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids;

type
  TDBGridEx = class(TDBGrid)
  private
    procedure WMMouseWheel(var Msg: TWMMouseWheel); message WM_MOUSEWHEEL;
  protected
    procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  public
    property VisibleColCount;
    property VisibleRowCount;
  end;

procedure Register;

implementation

{...........................................................................
...}

procedure Register;
begin
  RegisterComponents('MyComponents', [TDBGridEx]);
end;

{...........................................................................
...}

procedure TDBGridEx.KeyDown(var Key: Word; Shift: TShiftState);
begin
  if not Assigned(DataSource) or not Assigned(DataSource.DataSet) then Exit;
  case Key of
    33: begin //... page up
      DataSource.DataSet.MoveBy(-VisibleRowCount);
      Key := 0;
    end;
    34: begin //... page down
      DataSource.DataSet.MoveBy(VisibleRowCount);
      Key := 0;
    end;
    35: begin //... end
      DataSource.DataSet.Last;
      Key := 0;
    end;
    36: begin //... home
      DataSource.DataSet.First;
      Key := 0;
    end;
    38: begin //... up
      DataSource.DataSet.Prior;
      Key := 0;
    end;
    40: begin //... down
      DataSource.DataSet.Next;
      Key := 0;
    end;
  end;
  inherited;
end;

{...........................................................................
...}

procedure TDBGridEx.WMMouseWheel(var Msg: TWMMouseWheel);
begin
  if not Assigned(DataSource) or not Assigned(DataSource.DataSet) then Exit;
  if Msg.WheelDelta < 0 then
    DataSource.DataSet.MoveBy(3)
  else
    DataSource.DataSet.MoveBy(-3);
end;

{...........................................................................
...}


end.


----- Original Message -----
From: "Ladislav Novak" <lada.xt@volny.cz>
To: <delphi-l@clexpert.cz>
Sent: Saturday, August 07, 2004 12:49 AM
Subject: Mouse Roller & DBGrid


> Zdravim vsechny,
>
> a prosim o pomoc...
> Jak zaridit, abych pomoci rolleru mysi v DBGridu pokracoval i na dalsi
> stranku zaznamu...? Asi trochu hodne laicky receno..
> Zkratka momentalne mam v DBGridu zobrazenou stranku zaznamu a rollerem
> se muzu pohybovat pouze v ramci zaznamu teto stranky..
> Jak plynule pokracovat na dalsi...?
>
> D6, FB 1.5
>
> Diky moc,
>
> Lada
>
>